import os
domainname= os.environ.get('DOMAIN_NAME')
domainpath= '/u01/Oracle/Middleware/user_project/domains/%s' %domainname
password= os.environ.get('PASS_WORD')
adminport= os.environ.get('ADMIN_PORT')
"""
This script configures a JDBC data source as a System Module and deploys it
to the server
"""
print('domainpath : [%s]' % domainpath);
print('domainname : [%s]' % domainname);
print('password : [%s]' % password);
print('adminport : [%s]' % adminport);
readDomain("%s" % domainpath)
connect("weblogic","%s" % password,"t3://localhost:%s" %adminport)
edit()
# Change these names as necessary
dsname="Amplus-11g-qa"
server="AdminServer"
cd("Servers/"+server)
target=cmo
cd("../..")
startEdit()
# start creation
print 'Creating JDBCSystemResource with name '+dsname
jdbcSR = create("dsname","JDBCSystemResource")
##jdbcSR = create("test","JDBCSystemResource")
theJDBCResource = jdbcSR.getJDBCResource()
theJDBCResource.setName("myJDBCDataSource")
connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
connectionPoolParams.setConnectionReserveTimeoutSeconds(25)
connectionPoolParams.setMaxCapacity(100)
connectionPoolParams.setTestTableName("SYSTABLES")
dsParams = theJDBCResource.getJDBCDataSourceParams()
dsParams.addJNDIName("jdbc/AmplusDS")
driverParams = theJDBCResource.getJDBCDriverParams()
driverParams.setUrl("jdbc:oracle:thin:@10.143.169.120:1521:amplus")
driverParams.setDriverName("oracle.jdbc.OracleDriver")
driverParams.setPassword("dockertest")
# driverParams.setLoginDelaySeconds(60)
driverProperties = driverParams.getProperties()
proper = driverProperties.createProperty("user")
#proper.setName("user")
proper.setValue("dockertest")
proper1 = driverProperties.createProperty("DatabaseName")
#proper1.setName("DatabaseName")
proper1.setValue("jdbc:oracle:thin:@10.143.169.120:1521:amplus")
jdbcSR.addTarget(target)
save()
activate(block="true")
print 'Done configuring the data source'

